import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/home/Home.vue'

Vue.use(VueRouter)

const routes = [
  {//首页
    path: '/',
    name: 'Home',
    component: Home,
    children:[
      {path:"/",redirect:"/Index"},
      {path:"/Index",name:"Index",component:()=>import('@/views/home/index/Index.vue')},//首页
      {path:"/Classification",name:"Class",component:()=>import('@/views/home/classification/Classification.vue')},//分类
      {
        path:"/Cart",
        name:"Cart",
        component:()=>import('@/views/home/cart/Cart.vue')
      },//购物车
      { //购物车列表
        path:'/CartList',
        name:'CartList',
        component:()=>import('@/views/home/cart/CartList.vue')
      },
      { //结算详情页
        path:'/Payment',
        name:'Payment',
        component:()=>import('@/views/home/cart/Payment.vue')
      },
      {path:"/My",name:"My",component:()=>import('@/views/home/my/My.vue')},//我的
    ]
  },
  {//登录
    path: '/Login',
    name: 'login',
    component: ()=>import('@/views/login/Login.vue'),
  },
  {//结算页
    path:'/Details',
    name:"Details",
    component:()=>import('@/views/details/Details.vue')
  }
]

const router = new VueRouter({
  routes
})

// router.beforeEach((to,from,next)=>{
//   // console.log(to,from)
//   // if(to.path!='/Login'){
//   //   if(localStorage.getItem('phone')){
//   //     next()
//   //   }
//   // }
//   // next('/Login')
//   next()
// })
export default router
